unit untRelLivroMensal;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, untRelPadrao, Menus, cxLookAndFeelPainters, dxmdaset, IBQuery,
  ppParameter, ppBands, ppVar, ppCtrls, ppPrnabl, ppClass, ppCache, ppProd,
  ppReport, ppEndUsr, ppComm, ppRelatv, ppDB, ppDBPipe, DB,
  IBCustomDataSet, ImgList, cxGraphics, ActnList, StdCtrls, cxButtons,
  ExtCtrls,  cxSpinEdit, cxDBEdit, cxTextEdit, cxMaskEdit,
  cxDropDownEdit, cxLookupEdit, cxDBLookupEdit, cxDBLookupComboBox,
  cxLabel, cxControls, cxContainer, cxEdit, cxGroupBox, ppModule,
  daDataModule, cxLookAndFeels, dxSkinsCore, dxSkinBlack, dxSkinBlue,
  dxSkinCaramel, dxSkinCoffee, dxSkinDarkRoom, dxSkinDarkSide, dxSkinFoggy,
  dxSkinGlassOceans, dxSkiniMaginary, dxSkinLilian, dxSkinLiquidSky,
  dxSkinLondonLiquidSky, dxSkinMcSkin, dxSkinMoneyTwins,
  dxSkinOffice2007Black, dxSkinOffice2007Blue, dxSkinOffice2007Green,
  dxSkinOffice2007Pink, dxSkinOffice2007Silver, dxSkinOffice2010Black,
  dxSkinOffice2010Blue, dxSkinOffice2010Silver, dxSkinPumpkin, dxSkinSeven,
  dxSkinSharp, dxSkinSilver, dxSkinSpringTime, dxSkinStardust,
  dxSkinSummer2008, dxSkinsDefaultPainters, dxSkinValentine,
  dxSkinXmas2008Blue, ACBrBase, ACBrEnterTab;

type
  TfrmRelLivroMensal = class(TfrmRelPadrao)
    lstProdutores: TIBQuery;
    lstProdutoresCODIGO: TIntegerField;
    lstProdutoresNOME: TIBStringField;
    mtbFiltroANO_BASE: TIntegerField;
    mtbFiltroPRODUTOR: TIntegerField;
    cxGroupBox1: TcxGroupBox;
    cxLabel2: TcxLabel;
    cbProdutor: TcxDBLookupComboBox;
    cxDBSpinEdit1: TcxDBSpinEdit;
    cxLabel5: TcxLabel;
    edtRelCODIGO: TIntegerField;
    edtRelREL_LIVRO_MENSAL: TMemoField;
    edtRelCODIGO2: TIBStringField;
    DtlstRelDATA: TDateField;
    DtlstRelDATA_MOVTO: TDateField;
    DtlstRelNOME_CONTA: TIBStringField;
    DtlstRelDEBITO: TIBBCDField;
    DtlstRelCREDITO: TIBBCDField;
    DtlstRelSALDO: TIBBCDField;
    DtlstRelHISTORICO: TMemoField;
    DtlstRelPP_NOME: TIBStringField;
    DtlstRelPP_CPF_CNPJ: TIBStringField;
    DtlstRelPP_LOGRADOURO: TIBStringField;
    DtlstRelPP_NUMERO: TIBStringField;
    DtlstRelPP_BAIRRO: TIBStringField;
    DtlstRelPP_CIDADE: TIBStringField;
    DtlstRelPRODUTOR_NOME: TIBStringField;
    DtlstRelPRODUTOR_CPF_CNPJ: TIBStringField;
    DtlstRelPP_UF: TIBStringField;
    DtlstRelMES: TIBStringField;
    DtlstRelPP_LOGOTIPO: TBlobField;
    ppDadosLicenca: TppDBPipeline;
    ppLayoutRel: TppDBPipeline;
    ppRel: TppDBPipeline;
    Designer_Rel: TppDesigner;
    rptRel: TppReport;
    ppParameterList1: TppParameterList;
    ppTitleBand6: TppTitleBand;
    ppLine1: TppLine;
    ppLine2: TppLine;
    ppLabel1: TppLabel;
    ppSystemVariable2: TppSystemVariable;
    ppHeaderBand1: TppHeaderBand;
    ppDetailBand30: TppDetailBand;
    ppDBText3: TppDBText;
    ppDBText4: TppDBText;
    ppFooterBand5: TppFooterBand;
    ppLine3: TppLine;
    ppLine4: TppLine;
    ppSystemVariable1: TppSystemVariable;
    ppSummaryBand2: TppSummaryBand;
    ppGroup1: TppGroup;
    ppGroupHeaderBand1: TppGroupHeaderBand;
    ppDBText1: TppDBText;
    ppGroupFooterBand1: TppGroupFooterBand;
    ppGroup2: TppGroup;
    ppGroupHeaderBand2: TppGroupHeaderBand;
    ppDBText2: TppDBText;
    ppLabel2: TppLabel;
    ppLabel3: TppLabel;
    ppLabel4: TppLabel;
    ppLabel5: TppLabel;
    ppLabel6: TppLabel;
    ppLabel7: TppLabel;
    ppGroupFooterBand2: TppGroupFooterBand;
    daDataModule1: TdaDataModule;
    procedure FormShow(Sender: TObject);
    procedure ActOKExecute(Sender: TObject);
    procedure ActConfigurarExecute(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmRelLivroMensal: TfrmRelLivroMensal;

implementation

uses DateUtils;

{$R *.dfm}

procedure TfrmRelLivroMensal.FormShow(Sender: TObject);
begin
  inherited;

  lstProdutores.Close;
  lstProdutores.Open;
  mtbFiltroANO_BASE.Value := YearOf(date);
end;

procedure TfrmRelLivroMensal.ActOKExecute(Sender: TObject);
var
order  : string;
begin
  inherited;
  edtRel.close;
  edtRel.parambyname('codigo').value := 1;
  edtRel.Open;

  rptRel.Template.DatabaseSettings.Name := '1';
  rptRel.Template.LoadFromDatabase;

  DtlstRel.Close;
  DtlstRel.SQL.Text := sqloriginal + order;
  DtlstRel.ParamByName('produtor').value := mtbFiltroPRODUTOR.AsInteger;
  DtlstRel.ParamByName('ANO').value := mtbFiltroANO_BASE.AsInteger;
  DtlstRel.Open;

  rptRel.Print;
end;

procedure TfrmRelLivroMensal.ActConfigurarExecute(Sender: TObject);
begin
  inherited;
  ConfigRel(rptRel,Designer_Rel);
end;

end.
